home *** CD-ROM | disk | FTP | other *** search
- /*
- /* SoundMgr.h for system 6.0.6
- *
- * Copyright (c) 1990 Symantec Corporation. All rights reserved.
- *
- * These interfaces are based on material copyrighted
- * by Apple Computer, Inc., 1985-1990.
- *
- * Written 10/9/90 MYG based on the MPW sound.h of 6-14-90
- * Notes: "Time" is a low memory global defined in OSUtil.h Therefore
- * the type "Time" in the MPW header has been Redefined as "time".
- * Note the case!!!!
- *
- * Revised 10/16/90 MYG added error codes from Errors.h
- */
-
- #ifndef _SoundMgr_
- #define _SoundMgr_
-
- #ifndef _MacTypes_
- #include <MacTypes.h>
- #endif
-
-
- #ifndef _SANE_
- #if sizeof(double) == 12
- #include <SANE.h>
- #endif
- #endif
-
- #define const
-
- #define synthCodeRsrc 'snth'
- #define soundListRsrc 'snd '
-
- /* synthesizer numbers for SndNewChannel */
-
- #define noteSynth 1 /*note synthesizer*/
- #define waveTableSynth 3 /*wave table synthesizer*/
- #define sampledSynth 5 /*sampled sound synthesizer*/
-
- /* Param2 values */
-
- #define twelthRootTwo 1.05946309434
- #define infiniteTime 0x7FFFFFFF
-
- /* command numbers for SndDoCommand */
- enum {
- nullCmd,
- initCmd,
- freeCmd,
- quiteCmd,
- flushCmd,
- reInitCmd,
- waitCmd = 10,
- pauseCmd,
- resumeCmd,
- callBackCmd,
- syncCmd,
- emptyCmd,
- tickleCmd = 20,
- requestNextCmd,
- howOftenCmd,
- wakeUpCmd,
- availableCmd,
- versionCmd,
- totalLoadCmd,
- loadCmd,
- scaleCmd = 30,
- tempoCmd,
- noteCmd = 40,
- restCmd,
- freqCmd,
- ampCmd,
- timbreCmd,
- waveTableCmd = 60,
- phaseCmd,
- soundCmd = 80,
- bufferCmd,
- rateCmd,
- continueCmd,
- doubleBufferCmd,
- getRateCmd,
- sizeCmd = 90,
- convertCmd
- };
-
-
-
-
- #define stdQLength 128
- #define dataPointerFlag 0x8000
-
- #define waveInitChannelMask 0x07
- enum {
- waveInitChannel0 = 0x04,
- waveInitChannel1,
- waveInitChannel2,
- waveInitChannel3
- };
-
- #define initSRateMask 0x0030
- #define initStereoMask 0x00C0
- #define initChanLeft 0x0002 /*left stereo channel */
- #define initChanRight 0x0003 /*right stereo channel*/
- #define initSRate22k 0x0020 /*22k sampling rate*/
- #define initMono 0x0080 /*monophonic channel*/
- #define initStereo 0x00C0 /*stereo channel*/
- #define initNoInterp 0x0004 /*no Linear Interpolation with the SR Convert*/
- #define initNoSRC 0x0008
- #define initNoMultiChannel 0x1000
- #define initMACE3 0x0300
- #define initMACE6 0x0400
-
- #define stdSH 0x00
- #define extSH 0xFF
- #define cmpSH 0xFE
-
- enum {
- notCompressed,
- twoToOne,
- eightToThree,
- threeToOne,
- sixToOne
- };
-
- enum {
- outsideCmpSH,
- insideCmpSH
- };
-
- enum {
- aceSuccess,
- aceMemFull,
- aceNilBlock,
- aceBadComp,
- aceBadEncode,
- aceBadDest,
- aceBadCmd,
- sixToOnePacketSize = 8,
- threeToOnePacketSize = 16,
- leftOverBlockSize = 32,
- stateBlockSize = 64
- };
-
-
- #define firstSoundFormat 0x0001 /* general sound format */
- #define secondSoundFormat 0x0002 /* special sampled sound format */
-
- typedef long time; /* in half milliseconds */
-
- typedef unsigned char Wave[256];
- typedef Wave *WavePtr;
-
-
- #define sysBeepDisable 0x0000
- #define sysBeepEnable 0x0001
-
- /* unitTypes for AudioSelection.unitType */
- #define unitTypeNoSelection 0xFFFF
- #define unitTypeSeconds 0x0000
-
-
- #define dbBufferEmpty 0x00000000 /* Constants for SndPlayDoubleBuffer*/
- #define dbBufferEmptyMask 0xFFFFFFFE
- #define dbBufferReady 0x00000001
- #define dbBufferExhausted 0x00000002
- #define dbLastBuffer 0x00000004
-
-
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- /*
- /* Error Codes for Sound Manager and Sound Manager 7.0
- /*
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- enum {
- badParam = -213, /* invalid argument */
- noMoreRealTime, /* not enought CPU cycles left to add another task */
- channelNotBusy,
- buffersTooSmall, /* can not operate in the memory allowed */
- channelBusy, /* the Channel is being used for a PFD already */
- badFileFormat, /* was not type AIFF or was of bad format,corrupt */
- notEnoughBufferSpace, /* could not allocate enough memory */
- badFormat,
- badChannel,
- resProblem,
- queueFull,
- notEnoughHardware = -201,
- noHardware
- };
-
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- /*
- /* Structures for Sound Driver
- /*
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
-
- typedef unsigned char FreeWave[30001];
-
- struct FFSynthRec {
- short mode;
- Fixed count;
- FreeWave waveBytes;
- };
-
- typedef struct FFSynthRec FFSynthRec;
- typedef FFSynthRec *FFSynthPtr;
-
- struct Tone {
- short count;
- short amplitude;
- short duration;
- };
-
- typedef struct Tone Tone;
- typedef Tone Tones[5001];
-
- struct SWSynthRec {
- short mode;
- Tones triplets;
- };
-
- typedef struct SWSynthRec SWSynthRec;
- typedef SWSynthRec *SWSynthPtr;
-
- struct FTSoundRec {
- short duration;
- Fixed sound1Rate;
- long sound1Phase;
- Fixed sound2Rate;
- long sound2Phase;
- Fixed sound3Rate;
- long sound3Phase;
- Fixed sound4Rate;
- long sound4Phase;
- WavePtr sound1Wave;
- WavePtr sound2Wave;
- WavePtr sound3Wave;
- WavePtr sound4Wave;
- };
-
- typedef struct FTSoundRec FTSoundRec;
- typedef FTSoundRec *FTSndRecPtr;
-
- struct FTSynthRec {
- short mode;
- FTSndRecPtr sndRec;
- };
-
- typedef struct FTSynthRec FTSynthRec;
- typedef FTSynthRec *FTSynthPtr;
-
-
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- /*
- /* Structures for Sound Manager
- /*
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
-
-
- typedef struct SndCommand {
- unsigned short cmd;
- short param1;
- long param2;
- }SndCommand;
-
-
- typedef struct SndChannel *SndChannelPtr;
-
- #define SndCompletionProcPtr ProcPtr
- #define SndCallBackProcPtr ProcPtr
-
- /*typedef pascal void (*SndCompletionProcPtr)(void);*/
- /*typedef pascal Boolean (*SndCallBackProcPtr)(SndChannelPtr chan, SndCommand cmd);*/
- typedef ProcPtr SndModifierProcPtr;
-
-
- typedef struct SoundHeader
- {
- char * samplePtr; /* if NIL then samples are in sampleArea */
- unsigned long length;
- Fixed sampleRate;
- unsigned long loopStart,
- loopEnd;
- unsigned char encode; /* <hbs 12/20/88> header type */
- unsigned char baseNote; /* <hbs 12/20/88> basenote now byte */
- #ifndef __cplusplus
- char sampleArea[];
- #endif
- } SoundHeader;
-
- typedef SoundHeader *SoundHeaderPtr;
-
-
- typedef struct SndChannel {
- SndChannelPtr nextChan;
- Ptr firstMod;
- SndCallBackProcPtr callBack;
- long userInfo;
- long wait; /* The following is for internal Sound Manager use only.*/
- SndCommand cmdInProgress;
- short flags;
- short qLength;
- short qHead; /* next spot to read or -1 if empty */
- short qTail; /* next spot to write = qHead if full */
- SndCommand queue[128];
- } SndChannel;
-
-
-
- typedef struct ModifierStub {
- struct ModifierStub *nextStub;
- SndModifierProcPtr code;
- long userInfo;
- time count;
- time every;
- char flags;
- char hState;
- } ModifierStub;
-
- /*______________________ <hbs 1/10/89> structs for mace____________________________ */
-
-
- typedef struct{
- short stateVar[stateBlockSize] ;
- } StateBlock, *StateBlockPtr;
-
-
- typedef struct
- {
- unsigned long count;
- char sampleArea[leftOverBlockSize];
- }
- LeftOverBlock, *LeftOverBlockPtr;
-
-
- typedef struct
- {
- char *samplePtr; /* if nil then samples are in sample area */
- unsigned long numChannels; /* CAFF, number of channels mono = 1 */
- Fixed sampleRate; /* sample rate in Apples Fixed point representation */
- unsigned long loopStart; /* loopStart of sound before compression */
- unsigned long loopEnd; /* loopEnd of sound before compression */
- unsigned char encode; /* data structure used , stdSH, extSH, or cmpSH */
- unsigned char baseNote; /* same meaning as regular SoundHeader */
- unsigned long numFrames; /* length in frames ( packetFrames or sampleFrames */
- #if sizeof(double) == 12
- extended80 AIFFSampleRate;
- #else
- double AIFFSampleRate;
- #endif /* CAFF, IEEE sample rate */
- Ptr MarkerChunk; /* CAFF, sync track */
- Ptr FutureUse1; /* reserved by Apple */
- Ptr FutureUse2; /* reserved by Apple */
- StateBlockPtr StateVars; /* pointer to State Block */
- LeftOverBlockPtr LeftOverSamples; /* used to save truncated samples between compression calls */
- unsigned short compressionID; /* 0 means no compression, non zero means compressionID */
- unsigned short packetSize; /* CAFF, number of bits in compressed sample packet */
- unsigned short snthID; /* Resource ID of Sound Manager snth that contains NRT C/E */
- unsigned short sampleSize; /* CAFF, number of bits in non-compressed sample */
- #ifndef __cplusplus
- char sampleArea[]; /* space for when samples follow directly */
- #endif
- }
- CmpSoundHeader, *CmpSoundHeaderPtr;
-
- typedef struct
- {
- char *samplePtr; /* if nil then samples are in sample area */
- unsigned long numChannels; /* AIFF, number of channels, ie mono = 1 */
- Fixed sampleRate; /* sample rate in Apples Fixed point representation */
- unsigned long loopStart; /* same meaning as regular SoundHeader */
- unsigned long loopEnd; /* same meaning as regular SoundHeader */
- unsigned char encode; /* data structure used , stdSH, extSH, or cmpSH */
- unsigned char baseNote; /* same meaning as regular SoundHeader */
- unsigned long numSampleFrames; /* length in total number of frames */
- #if sizeof(double) == 12
- extended80 AIFFSampleRate;
- #else
- double AIFFSampleRate;
- #endif /* CAFF, IEEE sample rate */
- /* AIFF, IEEE sample rate */
- Ptr MarkerChunk; /* AIFF, sync track */
- Ptr InstrumentChunks; /* AIFF, */
- Ptr AESRecording; /* AIFF, */
- unsigned short sampleSize; /* AIFF, number of bits in sample */
- unsigned short FutureUse1; /* reserved by Apple */
- unsigned long FutureUse2; /* reserved by Apple */
- unsigned long FutureUse3; /* reserved by Apple */
- unsigned long FutureUse4; /* reserved by Apple */
- #ifndef __cplusplus
- char sampleArea[]; /* space for when samples follow directly */
- #endif
- }
- ExtSoundHeader, *ExtSoundHeaderPtr;
-
-
-
- typedef struct{
- short smMaxCPULoad;
- short smNumChannels;
- short smCurCPULoad;
- }
- SMStatus, *SMStatusPtr;
-
-
- typedef struct{
- Fixed scStartTime;
- Fixed scEndTime;
- Fixed scCurrentTime;
- Boolean scChannelBusy;
- Boolean scChannelDisposed;
- Boolean scChannelPaused;
- char scUnused;
- unsigned long scChannelAttributes;
- long scCPULoad;
- }
- SCStatus,*SCStatusPtr;
-
-
- typedef struct {
- long dbNumFrames;
- long dbFlags;
- long dbUserInfo[2];
- #ifndef __cplusplus
- char dbSoundData[];
- #endif
- } SndDoubleBuffer, *SndDoubleBufferPtr;
-
-
- typedef struct{
- long unitType;
- Fixed selStart;
- Fixed selEnd;
- }AudioSelection, *AudioSelectionPtr;
-
-
- typedef struct {
- short dbhNumChannels;
- short dbhSampleSize;
- short dbhCompressionID;
- short dbhPacketSize;
- Fixed dbhSampleRate;
- SndDoubleBufferPtr dbhBufferPtr[2];
- ProcPtr dbhDoubleBack;
- }
- SndDoubleBufferHeader, *SndDoubleBufferHeaderPtr;
-
- typedef struct ModRef {
- unsigned short modNumber;
- long modInit;
- } ModRef;
-
-
- typedef struct SndListResource {
- short format;
- short numModifiers;
- ModRef modifierPart[1]; /*This is a variable length array*/
- short numCommands;
- SndCommand commandPart[1]; /*This is a variable length array*/
- char dataPart[1]; /*This is a variable length array*/
- } SndListResource;
-
- typedef SndListResource *SndListPtr;
-
-
- pascal OSErr SndDoCommand(SndChannelPtr chan,const SndCommand *cmd,Boolean noWait)
- = 0xA803;
- pascal OSErr SndDoImmediate(SndChannelPtr chan,const SndCommand *cmd)
- = 0xA804;
- pascal OSErr SndNewChannel(SndChannelPtr *chan,short synth,long init,SndCallBackProcPtr userRoutine)
- = 0xA807;
- pascal OSErr SndDisposeChannel(SndChannelPtr chan,Boolean quietNow)
- = 0xA801;
- pascal OSErr SndPlay(SndChannelPtr chan,Handle sndHdl,Boolean async)
- = 0xA805;
- pascal OSErr SndControl(short id,SndCommand *cmd)
- = 0xA806;
-
-
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- /*
- /* New Enhanced Sound Manager 7.0 Calls <18 Aug 1989 NJC>
- /*
- /* These will soon be supported by a Glue Library so that all this ugly
- /* shit will disappear and the traps will look like non-indexed traps.
- /*
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
-
- #define MOVEL 0x203C
-
- /* constants for MACE in the dispatcher */
- #define MACEToolNum 16
- #define sMgrMACEVersion 0
- #define sMgrComp3to1 4
- #define sMgrExp1to3 8
- #define sMgrComp6to1 12
- #define sMgrExp1to6 16
-
- /* constants for Sound Manager Extensions in the dispatcher */
- #define sMgrToolNum 8
- #define sMgrSndStartFilePlay 3328 /* (13*256)+0 */
- #define sMgrSndPauseFilePlay 516 /* (2*256)+4 */
- #define sMgrSndStopFilePlay 776 /* (3*256)+8 */
- #define sMgrSndSoundManagerVersion 12
- #define sMgrSndChannelStatus 16
- #define sMgrSndManagerStatus 20
- #define sMgrSndGetSysBeepState 24
- #define sMgrSndSetSysBeepState 28
- #define sMgrSndPlayDoubleBuffer 32
- #define sMgrSndGetBufferStufferLoad 36
- #define sMgrSndGetMixerLoad 40
-
- pascal unsigned long
- SndSoundManagerVersion (void)
- = {MOVEL,sMgrSndSoundManagerVersion,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndStartFilePlay ( SndChannelPtr theChannel, short fRefNum,
- short resNum, long bufferSize, Ptr bufferPtr,
- AudioSelectionPtr theSelection, ProcPtr theCompletion, Boolean async)
- = {MOVEL,sMgrSndStartFilePlay,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndPauseFilePlay (SndChannelPtr theChannel)
- = {MOVEL,sMgrSndPauseFilePlay,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndStopFilePlay (SndChannelPtr theChannel, Boolean noWait)
- = {MOVEL,sMgrSndStopFilePlay,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndChannelStatus (SndChannelPtr theChannel,
- short theLength, SCStatusPtr theStatus)
- = {MOVEL,sMgrSndChannelStatus,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndManagerStatus (short theLength, SMStatusPtr theStatus)
- = {MOVEL,sMgrSndManagerStatus,sMgrToolNum,0xA800};
-
- pascal void
- SndGetSysBeepState ( short *sysBeepState)
- = {MOVEL,sMgrSndGetSysBeepState,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndSetSysBeepState (short sysBeepState)
- = {MOVEL,sMgrSndSetSysBeepState,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndPlayDoubleBuffer ( SndChannelPtr theChannel, SndDoubleBufferHeaderPtr theParams)
- = {MOVEL,sMgrSndPlayDoubleBuffer,sMgrToolNum,0xA800};
-
- pascal short
- SndGetBufferStufferLoad (short channelFeatures)
- = {MOVEL,sMgrSndGetBufferStufferLoad,sMgrToolNum,0xA800};
-
- pascal short
- SndGetMixerLoad (short numChannels)
- = {MOVEL,sMgrSndGetMixerLoad,sMgrToolNum,0xA800};
-
-
- pascal unsigned long
- MACEVersion ()
- = {MOVEL,sMgrMACEVersion,MACEToolNum,0xA800};
-
- pascal void Comp3to1 ( Ptr inBuffer, Ptr outBuffer, unsigned long Cnt, Ptr inState,
- Ptr outState, unsigned long numChannels, unsigned long whichChannel )
- = {MOVEL,sMgrComp3to1,MACEToolNum,0xA800};
-
- pascal void Exp1to3 ( Ptr inBuffer, Ptr outBuffer, unsigned long Cnt, Ptr inState,
- Ptr outState, unsigned long numChannels, unsigned long whichChannel)
- = {MOVEL,sMgrExp1to3,MACEToolNum,0xA800};
-
- pascal void Comp6to1 ( Ptr inBuffer, Ptr outBuffer, unsigned long Cnt, Ptr inState,
- Ptr outState, unsigned long numChannels, unsigned long whichChannel )
- = {MOVEL,sMgrComp6to1,MACEToolNum,0xA800};
-
- pascal void Exp1to6 ( Ptr inBuffer, Ptr outBuffer, unsigned long Cnt, Ptr inState,
- Ptr outState, unsigned long numChannels, unsigned long whichChannel)
- = {MOVEL,sMgrExp1to6,MACEToolNum,0xA800};
-
-
- pascal void SetSoundVol(short level);
- pascal void GetSoundVol(short *level);
- pascal void StartSound(Ptr synthRec,long numBytes,SndCompletionProcPtr completionRtn);
- pascal void StopSound(void);
- pascal Boolean SoundDone(void);
- pascal OSErr SndAddModifier(SndChannelPtr chan,SndModifierProcPtr modifier,
- short id,long init)
- = 0xA802;
-
-
- #endif
-
-
-